home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.4 KB | 260 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPullDM.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPULLDM_H
- #define FWPULLDM_H
-
- #ifndef FWMNUITM_H
- #include "FWMnuItm.h"
- #endif
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CMenuBar;
- class FW_CPrivOrderedCollection;
- class ODPart;
- class ODMenuBar;
-
- //========================================================================================
- // class FW_CPullDownMenu
- //========================================================================================
-
- class FW_CPullDownMenu
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPullDownMenu(Environment* ev);
-
- FW_CPullDownMenu(Environment* ev,
- const FW_CString& menuTitle);
-
- FW_CPullDownMenu(Environment* ev,
- FW_PResourceFile &resFile,
- FW_ResourceID resourceID,
- unsigned long stringID);
-
- FW_CPullDownMenu(Environment* ev,
- FW_CReadableStream& stream);
-
- virtual ~FW_CPullDownMenu();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- ODMenuID GetMenuID(Environment* ev) const;
- const ODPlatformMenu& GetPlatformMenu(Environment* ev) const;
-
- FW_Boolean IsAttachedToMenuBar(Environment* ev) const;
- FW_CMenuBar* GetMenuBar(Environment* ev) const;
-
- void DisableAll(Environment* ev);
- void EnableAll(Environment* ev);
-
- short CountItems(Environment* ev) const;
-
- ODCommandID GetCommandID(Environment* ev, short position) const; // position : one-based
-
- //----- Adding items -----
- void AppendTextItem(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItem(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItemAfterCommand(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendToggleItem(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItem(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItemAfterCommand(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendSubMenu(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu);
-
- void InsertSubMenu(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu,
- short afterItem);
-
- void InsertSubMenuAfterCommand(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu,
- ODCommandID afterCommand);
-
- void AppendSeparator(Environment* ev);
-
- void InsertSeparator(Environment* ev,
- short afterItem);
-
- void InsertSeparatorAfterCommand(Environment* ev,
- ODCommandID afterCommand);
-
- //----- Removing items -----
- void RemoveItem(Environment* ev,
- short position);
-
- //----- Archiving -----
- static void* Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Destroy(void* object, FW_ClassTypeConstant type);
- static void InitializeFromArchive(FW_CReadableStream& stream, FW_ClassTypeConstant type, void* object);
- static void Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
- void Flatten(Environment* ev, FW_CWritableStream& stream) const;
-
- // ----- Parent Menu Item
- FW_CMenuItem* GetParentMenuItem(Environment* ev) const;
- void SetParentMenuItem(Environment* ev,
- FW_CMenuItem* menuItem);
-
- // ----- Adopt Items
- void AdoptMenuItemLast(Environment* ev,
- FW_CMenuItem* menuItem);
- void AdoptMenuItemAfter(Environment* ev,
- FW_CMenuItem* menuItem,
- short afterItem);
-
-
- //----------------------------------------------------------------------------------------
- // Internal use only
- //
- public:
- void PrivInitialize(Environment* ev, const FW_CString& menuTitle);
-
- FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
-
- FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- void PrivAttachedToMenuBar(Environment* ev,
- ODPart* part,
- FW_CMenuBar* menuBar,
- ODMenuID beforeID);
- void PrivDetachedFromMenuBar(Environment* ev,
- FW_CMenuBar* menuBar);
-
- void PrivAttach(Environment* ev,
- FW_CMenuBar* menuBar);
- void PrivDetach(Environment* ev,
- FW_CMenuBar* menuBar);
-
- ODMenuID PrivAcquireMenuID(Environment* ev, FW_CMenuBar* menuBar);
- void PrivRelinquishMenuID(Environment* ev);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- ODMenuID fMenuID; // if -1 the menu is not attached
- ODPlatformMenu fPlatformMenu;
- FW_CMenuBar* fMenuBar; // if NULL the menu is not attached
- FW_TOrderedCollection<FW_CMenuItem>* fItems;
- FW_CMenuItem* fParentMenuItem; // NULL if not a submenu
- };
-
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetMenuID
- //----------------------------------------------------------------------------------------
- inline ODMenuID FW_CPullDownMenu::GetMenuID(Environment*) const
- {
- return fMenuID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetPlatformMenu
- //----------------------------------------------------------------------------------------
- inline const ODPlatformMenu& FW_CPullDownMenu::GetPlatformMenu(Environment*) const
- {
- return fPlatformMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::IsAttachedToMenuBar
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CPullDownMenu::IsAttachedToMenuBar(Environment*) const
- {
- return fMenuBar != NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetMenuBar
- //----------------------------------------------------------------------------------------
- inline FW_CMenuBar* FW_CPullDownMenu::GetMenuBar(Environment*) const
- {
- return fMenuBar;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetParentMenuItem
- //----------------------------------------------------------------------------------------
- inline FW_CMenuItem* FW_CPullDownMenu::GetParentMenuItem(Environment*) const
- {
- return fParentMenuItem;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::SetParentMenuItem
- //----------------------------------------------------------------------------------------
- inline void FW_CPullDownMenu::SetParentMenuItem(Environment*, FW_CMenuItem* menuItem)
- {
- fParentMenuItem = menuItem;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::CountItems
- //----------------------------------------------------------------------------------------
- inline short FW_CPullDownMenu::CountItems(Environment*) const
- {
- return (short) fItems->Count();
- }
-
- #endif
-